<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/inc/includemobile.jsp"%>
<c:choose>
	<c:when test="${param.method=='edit'}">
		<c:set var="title" value="修改账户信息"></c:set>
	</c:when>
	<c:when test="${param.method=='create'}">
		<c:set var="title" value="新建账户"></c:set>
	</c:when>
	<c:when test="${param.method=='show'}">
		<c:set var="title" value="账户详细信息"></c:set>
	</c:when>
</c:choose>

<html>
	<head>
		<title>${title}</title>
	</head>

	<body class="mobile">
		<br />
		<form id="form1" name="form1" action="/cnaps/userManage!save.do" method="post">
		  <center>
			<input type="hidden" name="method" value="${param.method}" />
			<input type="hidden" name="userid" value="${map.USERID}" />
			<table class="mobile" style="width: 90%;" align="center">
				<tr class="outHeader" >
					<td colspan="4">
						${title}
					</td>
				</tr>
				<tr height="20">
				    <td width="20%" align="center" class="outDetail">
						账户名称：<font color="red">*</font>
					</td>
					<td width="30%" align="left" class="outDetail2">
						<input type="text" name="nickname" value="${map.NICKNAME }"/>
					<td width="20%" align="center" class="outDetail">
						初始密码：<font color="red">*</font>
					</td>
					<td width="30%" align="left" class="outDetail2" >
						<input type="text" name="password" value="123456" />
					</td>
				</tr>
				<tr height="20">
				    <td width="20%" align="center" class="outDetail">
						E-mail：<font color="red">*</font>
					</td>
					<td width="30%" align="left" class="outDetail2">
						<input type="text" name="email" value="${map.EMAIL }"/>
					<td width="20%" align="center" class="outDetail">
						电话号码：<font color="red">*</font>
					</td>
					<td width="30%" align="left" class="outDetail2" >
						<input type="text" name="phonenumber" value="${map.PHONENUMBER }"/>
					</td>
				</tr>

			</table>
			</center>
			<br />
			<p align="center">
				<c:if test="${param.method!='show'}">
					<input type="button" class="btn" value="保 存" onclick="save(this);" />
				</c:if>
				<input type="button" class="btn" value="关 闭"
					onclick="window.close();" />
			</p>
		</form>

	</body>
	<script type="text/javascript">
	
	
       function errorCheck()
       { 
       	   if(!Validator.Validate("form1"))
       	     return false;
       	   
       	   var count = 0 ;
       	   
       	   count = getCheckBoxCheckedCount("form1","org_id");
       	   if(count==0)
       	   {
       	   	 alert('至少选择一个组织！');
       	   	 return false;
       	   }  
       	     
       	   //判断工号是否已存在
       	   var isUserExist=false;
       	   if('${method}'=='create')
       	   {
       	   		 var url = 'sys!checkUserExist.jspa';
				 var params="operator_id="+ form1.employee_id.value+'&node_id=${param.node_id}&method=${method}';
				
  				 var myAjax = new Ajax.Request( 
                     url,
                     {
                       method: 'get', 
                       parameters:params, 
                       onSuccess:function(req)
                       {
                       		 var result=req.responseText;
	  						 
						  	  if(result!=0)
						  	  {
						  	  	isUserExist=true; 
						  	  }
                       },
                       onFailure:function(){alert('error');},
                       asynchronous:false
                     }
                    );
                      // alert(isUserExist);
		       	   if(isUserExist==true)
		       	   {
		       	   	 alert('该工号已存在！');
		       	   	 return false; 
		       	   }
	
       	   }
       
       //判断手机号是否已存在
       	 var isMobileExist=false;
     	 var url1 = 'sys!checkMobileOnly.jspa';
		 var params1="id="+ form1.operator_id.value+'&method=${method}&node_id=${param.node_id}&mobile='+form1.mobile.value;
		
				 var myAjax = new Ajax.Request( 
                   url1,
                   {
                     method: 'get', 
                     parameters:params1, 
                     onSuccess:function(req)
                     {
                     		 var result1=req.responseText;
 						 
				  	  if(result1!=0)
				  	  {
				  	  	isMobileExist=true; 
				  	  }
                     },
                     onFailure:function(){alert('error');},
                     asynchronous:false
                   }
                  );
                    // alert(isUserExist);
       	   if(isMobileExist==true)
       	   {
       	   	 alert('该手机号已存在！');
       	   	 return false; 
       	   }
	   	
       	   return true;
       	   
       }
       
       function save(src)
       {
       		//防止重复提交
			//src.disabled=true;
			//if(!errorCheck())
			//{
			//	src.disabled=false;
			//	return false;
			//}
        
			form1.submit();		
       }
     </script>
</html>
